﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace uTILLIty.ChartBuilder.Designer
{
	static class Program
	{
		private static FileVersionInfo _fileInfo;

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			_fileInfo = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location);
			//Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			var form = GetMainForm();
			form.Text = BuildFormTitle("");
			Application.Run(form);
		}

		public static string BuildFormTitle(string text, params object[] args)
		{
			var title = string.Format("{0}", _fileInfo.ProductName);
			if (string.IsNullOrWhiteSpace(text))
				return title;

			return string.Format("{0} - {1}", title, string.Format(text, args ?? new object[0]));
		}

		private static ChartDesigner GetMainForm()
		{
			var form = new ChartDesigner();
			var controller = new ChartDesignerController();
			form.Controller = controller;
			return form;
		}
	}
}
